//
//  CustomView.m
//  Comma
//
//  Created by liuyunqing on 15/1/28.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "CustomView.h"
#import "GlobalMacro.h"
#import "LeftTableViewCell.h"

#define DIVIDEHEIGHT SCREEN_HEIGHT * 0.372 - 0.5
@implementation CustomView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.headerImg = [[UIImageView alloc] initWithFrame:CGRectMake(16, (DIVIDEHEIGHT - 80) / 2, 80, 80)];
        [_headerImg.layer setCornerRadius:40.0f];
        [_headerImg setClipsToBounds:YES];
        [self addSubview:_headerImg];
        
        self.headerButton = [[UIButton alloc] initWithFrame:CGRectMake(16, (DIVIDEHEIGHT - 80) / 2, 80, 80)];
        [_headerButton.layer setCornerRadius:40.0f];
        [_headerButton setClipsToBounds:YES];
        [self addSubview:_headerButton];
        
        self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(96, (DIVIDEHEIGHT - 80) / 2 + 13, SCREEN_WIDTH / 3 * 2 - 96, 18)];
        [_nameLabel setFont:[UIFont systemFontOfSize:14.0f]];
        [_nameLabel setTextAlignment:NSTextAlignmentCenter];
        [self addSubview:_nameLabel];
        
        self.nameButton = [[UIButton alloc] initWithFrame:CGRectMake(96, (DIVIDEHEIGHT - 80) / 2 + 13, SCREEN_WIDTH / 3 * 2 - 96, 18)];
        [self addSubview:_nameButton];
        
        self.schoolLabel = [[UILabel alloc] initWithFrame:CGRectMake(96, (DIVIDEHEIGHT - 80) / 2 + 45, SCREEN_WIDTH / 3 * 2 - 96, 18)];
        [_schoolLabel setFont:[UIFont fontWithName:@"Helvetica" size:11.0f]];
        [_schoolLabel setTextAlignment:NSTextAlignmentCenter];
        [_schoolLabel setTextColor:TEXTERGRAY];
        [self addSubview:_schoolLabel];
        
        self.instituteLabel = [[UILabel alloc] initWithFrame:CGRectMake(96, (DIVIDEHEIGHT - 80) / 2 + 63, SCREEN_WIDTH / 3 * 2 - 96, 18)];
        [_instituteLabel setTextAlignment:NSTextAlignmentCenter];
        [_instituteLabel setFont:[UIFont fontWithName:@"Helvetica" size:11.0f]];
        [_instituteLabel setTextColor:TEXTERGRAY];
        [self addSubview:_instituteLabel];
        // 画线
        UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, DIVIDEHEIGHT, SCREEN_WIDTH, 0.5)];
        [line setBackgroundColor:LINEERGRAY];
        [self addSubview:line];
        
        // 页面分割线
        self.lineA = [[UIView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH / 3 * 2 - 0.5, 0, 0.5, SCREEN_HEIGHT)];
        [_lineA setBackgroundColor:LINEERGRAY];
        [self addSubview:_lineA];
    
        // 设置
        self.settingButton = [[UIButton alloc] initWithFrame:CGRectMake(16, SCREEN_HEIGHT - 46, 32, 32)];
        [_settingButton setTag:104];
        [_settingButton setTitle:@"设置" forState:UIControlStateNormal];
        [_settingButton.titleLabel setFont:[UIFont systemFontOfSize:0]];
        [_settingButton setBackgroundImage:[UIImage imageNamed:@"Button_set_up.pdf"] forState:UIControlStateNormal];
        [self addSubview:_settingButton];
        [self createTableView];
    }
    return self;
}

- (void)createTableView
{
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, DIVIDEHEIGHT + 0.5, SCREEN_WIDTH / 3 * 2 - 0.5, SCREEN_HEIGHT - 348) style:UITableViewStylePlain];
    [_tableView registerClass:[LeftTableViewCell class] forCellReuseIdentifier:@"buttonCell"];
    _tableView.scrollEnabled = NO;
    [self addSubview:_tableView];
    _tableView.tableFooterView = [[UIView alloc] init];
}




@end
